import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

class TwelveDays {

    private Map<String, String> days;
    private Stack<String> verseStack;

    {
        days = new HashMap<>() {
        };
        days.put("1", "first");
        days.put("2", "second");
        days.put("3", "third");
        days.put("4", "fourth");
        days.put("5", "fifth");
        days.put("6", "sixth");
        days.put("7", "seventh");
        days.put("8", "eighth");
        days.put("9", "ninth");
        days.put("10", "tenth");
        days.put("11", "eleventh");
        days.put("12", "twelfth");

        verseStack = new Stack<>();
        verseStack.push("a Partridge in a Pear Tree");
        verseStack.push("two Turtle Doves");
        verseStack.push("three French Hens");
        verseStack.push("four Calling Birds");
        verseStack.push("five Gold Rings");
        verseStack.push("six Geese-a-Laying");
        verseStack.push("seven Swans-a-Swimming");
        verseStack.push("eight Maids-a-Milking");
        verseStack.push("nine Ladies Dancing");
        verseStack.push("ten Lords-a-Leaping");
        verseStack.push("eleven Pipers Piping");
        verseStack.push("twelve Drummers Drumming");

    }

    String verse(int verseNumber) {
        StringBuilder sb = new StringBuilder();

        sb.append(String.format("On the %s day of Christmas my true love gave to me, ", days.get(Integer.toString(verseNumber))));
        for (int i = verseNumber; i > 1; i--) {
            sb.append(this.verseStack.get(i-1));
            sb.append(", ");
        }

        if (verseNumber == 1){
            sb.append(this.verseStack.get(0));
        }else{
            sb.append(String.format("and %s", this.verseStack.get(0)));
        }
        sb.append(".");
        sb.append("\n");

        return sb.toString();
    }

    String verses(int startVerse, int endVerse) {
        StringBuilder sb = new StringBuilder();
        for (int i = startVerse; i <= endVerse; i++) {
            sb.append(this.verse(i));
            if (i != endVerse){
                sb.append("\n");
            }
        }

        return sb.toString();
    }

    String sing() {
        return this.verses(1, 12);
    }
}
